﻿using System.Data;

namespace _04_简单工厂;

public class 简单工厂
{

    public interface IDao
    {
        IDbConnection GetConnection();
    }

    class MsSqlDao : IDao
    {
        public IDbConnection GetConnection()
        {
            throw new NotImplementedException();
        }
    }

    class MySqlDao : IDao
    {
        public IDbConnection GetConnection()
        {
            throw new NotImplementedException();
        }
    }


    public static class Factory
    {
        public static IDao Create(string dbType)
        {
            switch (dbType)
            {
                case "Sql": return new MsSqlDao();
                case "MySql": return new MySqlDao();
                default: throw new ArgumentNullException("未找到对应的DbConnection");
            }
        }
    }
}